package com.gientech.sys.wealthMange;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gientech.common.util.MyStringUtil;
import com.gientech.common.view.DataGrid;
import com.gientech.core.base.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
@Transactional
public class SysWealthManageService extends BaseService<SysWealthManageMapper, SysWealthManage> {

    /**
     * 【1】查询和分页
     *
     * @param dto
     *
     * @return
     */

    public DataGrid<SysWealthManageVO> listWealthManage(SysWealthManageDTO4List dto) {
        log.info("【查询条件--对私理财】" + dto);

        // 【1】 处理模糊查询条件的like(有3个方法addObjectLike，addObjectLikeLeft，addObjectLikeRight)
        MyStringUtil.addObjectLike(dto, "");

        // 【2】处理前端传入排序条件
        dto.setOrderBy(MyStringUtil.getOrderBy(dto.getSort(), dto.getOrder(), "a.WEALTH_ID asc"));

        // 【3】构造分页参数
        Page<SysWealthManageVO> page = new Page<>(dto.getPageNo(), dto.getPageSize());


        return new DataGrid<SysWealthManageVO>(this.getBaseMapper().getSysWealthManageList(page, dto), page.getTotal());
    }
}
